import { createRouter, createWebHashHistory } from 'vue-router';

//动态路由
export const permissionRouter = [
    {
        name:"Permission",
        path:"/permission",
        component:()=>import("@/view/layout/index.vue"),
        redirect:{path:'/permission/user'},
        children:[
            {
                name:"User",
                path:"/permission/user",
                component:()=>import('@/view/permission/user/index.vue'),
                meta:{title:"用户管理",hidden:false,icon:"UserFilled"}
            },
            {
                name:"Role",
                path:"/permission/role",
                component:()=>import('@/view/permission/role/index.vue'),
                meta:{title:"角色管理",hidden:false,icon:'Avatar'}
            },
            {
                name:"Menu",
                path:"/permission/menu",
                component:()=>import('@/view/permission/menu/index.vue'),
                meta:{title:"菜单管理",hidden:false,icon:"Grid"}
            }
        ],
        meta:{title:"权限管理",hidden:false,icon:"Lock"}
    },
    {
        name:"Product",
        path:"/product",
        component:()=>import("@/view/layout/index.vue"),
        redirect:{path:"/product/trademark"},
        children:[
            {
                name:"Trademark",
                path:"/product/trademark",
                component:()=>import('@/view/product/trademark/index.vue'),
                meta:{title:"品牌管理",hidden:false,icon:"ChromeFilled"}
            },
            {
                name:"Attr",
                path:"/product/attr",
                component:()=>import('@/view/product/attr/index.vue'),
                meta:{title:"属性管理",hidden:false,icon:"Management"}
            },
            {
                name:"Spu",
                path:"/product/spu",
                component:()=>import('@/view/product/spu/index.vue'),
                meta:{title:"spu管理",hidden:false,icon:"Briefcase"}
            },
            {
                name:"Sku",
                path:"/product/sku",
                component:()=>import('@/view/product/sku/index.vue'),
                meta:{title:"sku管理",hidden:false,icon:"TrendCharts"}
            }
        ],
        meta:{title:"商品管理",hidden:false,icon:"ShoppingBag"}
    }
]

//常量路由配置
export const constantRouter = [
    {
        name:'login',
        path:'/login',
        component:() => import('@/view/login/index.vue'),
        meta:{title:"登录",hidden:true,icon:""}
    },
    {
        name:'layout',
        path:'/',
        component:() => import('@/view/layout/index.vue'),
        redirect:{path:"/home"},
        children:[
            {
                name:"Home",
                path:"/home",
                component:()=>import('@/view/home/index.vue'),
                meta:{title:"首页",hidden:false,icon:"House"}
            }
        ],
        meta:{title:"layout",hidden:false,icon:"House"}
    },
    {
        name:"Screen",
        path:"/screen",
        component:()=>import("@/view/screen/index.vue"),
        meta:{title:"数据大屏",hidden:false,icon:"Monitor"}
    },
    {
        name:'404',
        path:'/404',
        component:() => import('@/view/error/index.vue'),
        meta:{title:"404",hidden:true}
    }
]

//任意路由配置
export const anyRouter = [
    {
        name:'any',
        path:'/:pathMatch(.*)*',
        redirect:'/404',
        meta:{hidden:true}
    }
]


let router = createRouter({
    history:createWebHashHistory(),
    routes:constantRouter,  //当前仅注册了常量路由，其它路径在获取用户权限信息后进行动态添加
    //滚动行为
    scrollBehavior(){
        return{
            left:0,
            top:0
        }
    }
})



export default router;